package com.atguigu.dga230301.governance.mapper;

import com.atguigu.dga230301.governance.bean.GovernanceAssessGlobal;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 治理总考评表 Mapper 接口
 * </p>
 *
 * @author zhangjunyi
 * @since 2023-07-05
 */
@Mapper
@DS("dga")
public interface GovernanceAssessGlobalMapper extends BaseMapper<GovernanceAssessGlobal> {

    @Select("SELECT\n" +
            "               assess_date,  \n" +
            "               AVG(  score_spec_avg ) score_spec ,\n" +
            "               AVG(  score_storage_avg ) score_storage ,\n" +
            "               AVG(  score_calc_avg ) score_calc ,\n" +
            "               AVG(  score_quality_avg ) score_quality ,\n" +
            "               AVG(  score_security_avg ) score_security ,\n" +
            "               AVG(  score_on_type_weight )  score   ,\n" +
            "               COUNT(*) table_num,\n" +
            "               SUM(problem_num) problem_num,\n" +
            "               NOW() create_time\n" +
            "             FROM  governance_assess_table ad WHERE assess_date= #{assessDate} "
    )
    public List<GovernanceAssessGlobal> selectGlobalScore(@Param("assessDate") String assessDate);
}
